import { Component } from '@angular/core';
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
import { DemoAction, DemoSelector } from '../../store/demo';
import { Store } from '@ngxs/store';

@Component({
  selector: 'app-menu-list',
  templateUrl: './menu-list.component.html',
  styleUrls: ['./menu-list.component.scss'],
})
export class MenuListComponent {
  @AutoUnsubscribe() list$ = this.store.select(DemoSelector.list);

  constructor(
      private store: Store,
  ) {
  }

  newMenu() {
    this.store.dispatch(new DemoAction.CreateMenu());
  }

  editMenu(data: any) {
    this.store.dispatch(new DemoAction.EditMenu(data));
  }

  deleteMenu(data: any) {
    this.store.dispatch(new DemoAction.DeleteMenu(data));
  }
}
